package bintree.heap;

/**
 * 基于最大堆的优先级队列,值越大优先级越高
 * 队首元素就是优先级最大的元素(值最大)
 */

import stack_queue.queue.IQueue;

public class PriorityQueue implements IQueue<Integer> {
    MaxHeap heap = new MaxHeap();
    public PriorityQueue(){
        heap = new MaxHeap();
    }

    @Override
    public void offer(Integer val) {
        heap.add(val);
    }

    @Override
    public Integer poll() {
        return heap.extractMax();
    }

    @Override
    public Integer peek() {
        return heap.peekMax();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }
}
